<?php

/*
php cephalopod-client.php --listen-ip-address=127.0.0.1 --listen-port=9001 --server-ip-address=127.0.0.1 --server-listen-port=9002
*/

require_once __DIR__ . '/vendor/autoload.php';

$options = getopt('', [
    'no-color::',
    'listen-ip-address::',
    'listen-port::',
    'server-ip-address::',
    'server-listen-port::',
]);

Cephalopod\LogRecorder::setEnableColor(!isset($options['no-color']));

$listenIpAddress = $options['listen-ip-address'] ?? '127.0.0.1';
$listenPort = $options['listen-port'] ?? 9001;
$serverIpAddress = $options['server-ip-address'] ?? '127.0.0.1';
$serverListenPort = $options['server-listen-port'] ?? 9002;

echo "listen ip,listen port,server ip,server port:$listenIpAddress,$listenPort,$serverIpAddress,$serverListenPort" . PHP_EOL;

$client = new Cephalopod\SSL\Client();
$client->setListenIpAddress($listenIpAddress);
$client->setListenPort($listenPort);
$client->setServerIpAddress($serverIpAddress);
$client->setServerListenPort($serverListenPort);
$client->setServerPublicKey(__DIR__ . '/etc/cephalopod/local/remote_public.pem');
$client->setClientPrivateKey(__DIR__ . '/etc/cephalopod/local/local_private.pem');
$client->run();
